Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: shuffle code and responsibility of LocalState #49

Merged
merged 8 commits into from
Nov 20, 2023

Conversation

augustoccesar
Copy link
Collaborator

Description

This changes make so that we stop using methods from the start command around the code.
To achieve this, the responsibility of loading and saving the state is now part of the implementation
of the LocalState itself.

Other notable changes

  • Instead of passing around a Tuple for the local and remote StorableSession, now there is a ServerConfig which
    holds a local and remote fields. Where this struct is located could be moved, but didn't gave that much thought.

Copy link
Contributor

@ostenbom ostenbom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

Comment on lines +42 to +49
let server_config = ServerConfig::from(&state);

let server_session_name = load_config(
&state.linkup.remote,
&state.linkup.session_name,
remote_server_conf,
server_config.remote,
)?;
let local_session_name = load_config(&local_url, &server_session_name, local_server_conf)?;
let local_session_name = load_config(&local_url, &server_session_name, server_config.local)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍 Cool!

Comment on lines 104 to 127
.map(|local_service| StorableService {
name: local_service.name.clone(),
location: if local_service.current == ServiceTarget::Remote {
local_service.remote.clone()
} else {
local_service.local.clone()
},
rewrites: Some(local_service.rewrites.clone()),
})
.collect::<Vec<StorableService>>();

let remote_server_services = state
.services
.iter()
.map(|local_service| StorableService {
name: local_service.name.clone(),
location: if local_service.current == ServiceTarget::Remote {
local_service.remote.clone()
} else {
state.linkup.tunnel.clone()
},
rewrites: Some(local_service.rewrites.clone()),
})
.collect::<Vec<StorableService>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the local_service variable name in the map here is confusing, maybe just service?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or switch local to remote in the remote case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point! Changed on 28055f6

@augustoccesar augustoccesar merged commit 750ed33 into main Nov 20, 2023
4 checks passed
@augustoccesar augustoccesar deleted the refactor/improvements branch November 20, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants